package fina2.dcs.system;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.annotation.ejb.LocalBinding;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;

@Stateful
@Name("userMenuSession")
@Scope(ScopeType.SESSION)
@LocalBinding(jndiBinding = "SysUserMenuSession/local")
@AutoCreate
public class SysUserMenuSession implements SysUserMenuLocal,Serializable {
	@PersistenceContext
	private EntityManager em;
	
	@Logger
	private Log log;
	
	public List<SysUserMenu> getUserMenus(BigDecimal userId) {
		List<SysUserMenu> userMenus = new ArrayList<SysUserMenu>();
		try {
			userMenus = (List<SysUserMenu>)em.createQuery("FROM " + SysUserMenu.class.getName() + " um WHERE um.userMenuPk.userId=:userId").setParameter("userId", userId);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
		}
		return userMenus;
	}

	@Remove
	public void remove() {

	}

}
